<?php

namespace App\Models;

use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class UsersModel extends Authenticatable
{
    use HasApiTokens,Notifiable;

    protected $table    = 'users'; //定义表名
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['username', 'email', 'openid', 'password'];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * 自定义用Passport授权登录：用户名+密码
     * @author Jamie<327240570@qq.com>
     * @since  2017-08-11T19:39:06+0800
     * @param  [type]                   $username [description]
     * @return [type]                             [description]
     */
    public function findForPassport($username) {
        return self::where('username', $username)->first();
    }
}
